﻿#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QTcpSocket>

class TcpClient : public QTcpSocket
{
    Q_OBJECT
public:
    explicit TcpClient(QObject *parent = nullptr);
    ~TcpClient();
    bool connectHost(const QString &ip, int port);
    bool disconnect();
    bool isConnected();
    void accepted(qintptr sockDesc);
    int send(const QByteArray &data);

signals:
    void readbuf(QString data);

public:
    void onConnected() {};
    void onDisconnected() {};
    void onReceived(const QByteArray &data);;

private slots:
    void slot_connected();
    void slot_readData();
    void slot_disconnected();
};

#endif // TCPCLIENT_H
